; fe3util.asm
; fe3 specific utility routines

	.export page2buf
	.export buf2page
	.export pagebuf

	.segment "DATA"
	
pagebuf:	.res 256

;
;	Copy a page in memory to buffer
;	INPUT:
;		A ... page number (high byte of memory address)
;

page2buf:	sta @p2b_lda+2
			ldx #0
@p2b_loop:
@p2b_lda:	lda $F000, x
			sta pagebuf, x
			inx
			bne @p2b_loop
			rts

;
;	Copy page buffer to memory
;	INPUT:
;		A ... page number (high byte of memory address)
;

buf2page:	sta @b2p_sta+2
			ldx #0
@b2p_loop:	lda pagebuf, x
@b2p_sta:	sta $F000, x
			inx
			bne @b2p_loop
			rts
